import api from "@/api/index";
import {encrypt} from "@/utils/AES";

export async function loginApi(data){
    return  await api({method:'post', url:'/api/auth/login_v1', data})
}

export async function reqApi(data){
    return  await api({method:'post', url:'/api/auth/reg_v2', data})
}

// 文件上传
export async function uploadV2(data){
    console.log(data,'file')
    let res = await api({
        method:'post',
        url:'/api/file/oss/uploadV2',
        headers: {
            'Content-Type': 'multipart/form-data'
        },
        data:{file:data.file}
    })

    return res.data
}


// 上传头像
export async function changeHeadLogo(data){
    return  await api({method:'post', url:'/api/auth/changeHeadLogo', data})
}


// 获取用户信息

export async function getUserInfo(){
    let res = await api({method:'get', url:'/api/auth/userInfoV2'})
    return res.data
}
// 获取用户余额
export async function getBalance(){
    let res = await api({method:'get',url:'/api/auth/getUserBalance'})
    return res.data
}

// 获取图形验证码
export async function getCode(){
    let res = await api({method:'post',url:'/api/auth/getValidateCodeV2'})
    return res.data
}
// 获取信誉分
export async function getCreditConfig(){
    let res = await api({method:'post',url:'/api/credit/getCreditConfig'})
    return res.data
}


// 获取地区编码
export async function countryCode(){
    return  await api({method:'get', url:'/api/content/countryCode'})
}

// 客服链接集合
export async function getCustomerServiceLinkV2(){
    return  await api({method:'get', url:'/api/content/getCustomerServiceLinkV2'})
}

// 钱包 - 查询常用绑定通道
export async function walletAddressSelect(){
    return  await api({method:'get', url:'/api/user/wallet/address/select'})
}

// 钱包 - 查询自己的钱包
export async function walletAddressList(){
    return  await api({method:'get', url:'/api/user/wallet/address/list'})
}
// 钱包 - 自己的钱包
export async function getWalletAddress(){
    return  await api({method:'get', url:'/api/auth/getWalletAddress'})
}

// 钱包 - 设置自己的钱包
export async function setWalletAddress(params){
    return  await api({
        method:'post',
        url:'/api/auth/setWalletAddress',
        data: params
    })
}

// 收益记录
export async function incomeList(params){
    return  await api({
        method:'post',
        url:'/api/auth/incomeList',
        data: params
    })
}

// 购买记录
export async function vipPurchaseList(params){
    return  await api({
        method:'post',
        url:'/api/auth/vipPurchaseList',
        data: params
    })
}

// 提现
export async function createWithdrawOrder(params){
    let form = {
        address: params.walletAddress,
        amount:params.money,
        channelName: "qqq",
        payPassword: encrypt(params.password)
    }
    return  await api({
        method:'post',
        url:'/api/pay/createWithdrawOrder',
        data: form
    })
}

// 提现记录
export async function withdrawList(params){
    return  await api({
        method:'post',
        url:'/api/auth/withdrawList',
        data: params
    })
}

// 充值渠道列表
export async function payChannel(params){
    return  await api({
        method:'post',
        url:'/api/content/payChannel',
        data: params
    })
}

// 充值
export async function createRechargeOrder(params){
    return  await api({
        method:'post',
        url:'/api/pay/createRechargeOrder',
        data: params
    })
}

// 充值记录
export async function rechargeList(params){
    return  await api({
        method:'post',
        url:'/api/auth/rechargeList',
        data: params
    })
}

// 修改登录密码
export async function changePassword(data){
    let p = {newPassword:encrypt(data.newPassword),oldPassword:encrypt(data.oldPassword)}
    let res =  await api({method:'post', url:'/api/auth/changePassword',data:p})
    return res.data
}
// 修改交易密码
export async function changePayPassword(data){
    let p = {newPassword:encrypt(data.newPassword),oldPassword:encrypt(data.oldPassword)}
    let res =  await api({method:'post', url:'/api/auth/changePayPassword',data:p})
    return res.data
}
// 获取邀请码
export async function invitation(data){
    let res =  await api({method:'get', url:'/api/auth/invitation',data})
    return res.data
}
// 获取团队信息
export async function teamReport(data){
    let res =  await api({method:'get', url:'/api/auth/teamReport',data})
    let level =  await api({method:'post', url:'/api/tm/getDicLevel',data})
    return {list : res.data,level:level.data}
}
// 获取app下载链接
export async function getAppDownLoadUrl(data){
    let res =  await api({method:'post', url:'/api/auth/getAppDownLoadUrl',data})
    return res.data
}

// 首页基本信息
export async function newsRecord(data){
    let res = await api({method:'post',url:'api/content/officialNews',data})
    return res.data
}

// 首页基本信息
export async function getBanner(data){
    let res = await api({method:'get',url:'/api/content/banner',data})
    return res.data
}
// 获取文本信息
export async function getSysParm(data){
    let res = await api({method:'post',url:'/api/content/sysParm',data})
    return res.data
}

// 获取帮助列表
export async function getTutorialCenter(data){
    let res = await api({method:'post',url:'/api/auth/getTutorialCenter',data})
    return res.data
}
// 获取帮助列表
export async function getLikeTaskTypeList(data){
    let res = await api({method:'get',url:'/api/taskOrder/getLikeTaskTypeList',data})
    return res.data
}

// 任务列表
export async function getLikeTaskList(data){
    let res = await api({method:'post',url:'/api/taskOrder/getLikeTaskList',data})
    return res.data
}
// 获取订单
export async function selectTaskOrderNumByUserId(data){
    let res = await api({method:'post',url:'/api/taskOrder/selectTaskOrderNumByUserId',data})
    return res.data
}
// 订单列表
export async function selectTaskOrder(data){
    let res = await api({method:'post',url:'/api/taskOrder/selectTaskOrder',data})
    return res.data
}
// VIP 列表
export async function vipMessage(data){
    let res = await api({method:'get',url:'/api/content/vipMessage',data})
    return res.data
}
// 领取任务
export async function addTaskOrder(data){
    let res = await api({method:'post',url:'/api/taskOrder/addTaskOrder',data})
    return res.data
}
// 获取等级
export async function getDicLevel(data){
    let res = await api({method:'post',url:'api/tm/getDicLevel',data})
    return res.data
}
//获取队伍队员
export async function newGetTeam(data){
    let res = await api({method:'post',url:'/api/tm/newGetTeam',data})
    return res.data
}
//删除订单记录
export async function delTaskOrder(data){
    let res = await api({method:'post',url:'/api/taskOrder/delTaskOrder',params:{idw:data}})
    return res.data
}

//上传订单
    export async function applyTaskOrderApproval(data){
    let res = await api({method:'post',url:'/api/taskOrder/applyTaskOrderApproval',data}    )
    return res.data
}

//获取充值方式
export async function getChannelTypeIsopen(data){
    let res = await api({method:'post',url:'/api/auth/getChannelTypeIsopen',data})
    return res.data
}

// 获取首页信息
export async function HomeIncome(){
    let res = await api({method:'get',url:'/api/home/income'})
    let data = await api({method:'get',url:'/api/home/selectMemberData'})
    return {income:res.data,member:data.data}
}

// 获取提现页面内容
export async function getWithDraw(data){
    let pwdStatus = await api({method:'get',url:'/api/auth/getPayPasswordStatus'})
    let wallet = await api({method:'get',url:'/api/auth/getWalletAddress'})
    let fee = await api({method:'post',url:'/api/auth/handlingFee'})
    let balance = await api({method:'get',url:'/api/auth/getUserBalance'})
    let content = await api({method:'post',url:'/api/content/sysParm',data})
    return {
        pwdStatus:pwdStatus.data,
        wallet: wallet.data ,
        ...fee.data,
        balance:balance.data,
        ...content.data,
    }

}
